<?php

namespace app\admin\model\booking;

use think\Model;

class HouseForm extends Model
{

    // 表名
    protected $name = 'booking_house_form';

    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = false;

    // 追加属性
    protected $append = [];

    public static function init()
    {
    }

    /**
     * 更新自定义数据
     *
     * @return void
     */
    public static function updateDiyData($data)
    {
        if (isset($data['house_id']) && !empty($data['house_id'])) {
            $row = self::where('house_id', $data['house_id'])->find();
            if ($row) {
                $row->allowField(true)->save($data);
            } else {
                (new self())->allowField(true)->save($data);
            }
        }
    }
}
